home *** CD-ROM | disk | FTP | other *** search
- package components
- {
- import flash.text.Font;
- import mx.controls.Text;
- import mx.events.PropertyChangeEvent;
- import mx.styles.StyleManager;
-
- public class LocalizedText extends Text
- {
- private static var fontArray:Array = Font.enumerateFonts(false);
-
- private var isFontRetrieved:Boolean = false;
-
- private var defaultAppFontFamily:String;
-
- private var _resourceName:String;
-
- private var _resourceParams:Array;
-
- private var _bundleName:String;
-
- private var _useHTML:Boolean = false;
-
- private var cachedEmbeddedFont:Font;
-
- public function LocalizedText()
- {
- super();
- this.selectable = false;
- }
-
- private function set _143661260resourceParams(param1:Array) : void
- {
- trace(this.id + " set resourceName: " + this.resourceName);
- this._resourceParams = param1;
- invalidateProperties();
- }
-
- [Bindable(event="propertyChange")]
- public function set resourceName(param1:String) : void
- {
- var _loc2_:Object = this.resourceName;
- if(_loc2_ !== param1)
- {
- this._384566343resourceName = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"resourceName",_loc2_,param1));
- }
- }
-
- override protected function commitProperties() : void
- {
- if(this.resourceName)
- {
- if(this.useHTML)
- {
- htmlText = this.localizeText();
- }
- else
- {
- text = this.localizeText();
- }
- }
- super.commitProperties();
- }
-
- private function set _384566343resourceName(param1:String) : void
- {
- this._resourceName = param1;
- invalidateProperties();
- }
-
- private function set _1377046061bundleName(param1:String) : void
- {
- this._bundleName = param1;
- invalidateProperties();
- }
-
- protected function localizeText() : String
- {
- return LocalizationManager.getInstance().getString(this.resourceName,this.bundleName,this.resourceParams);
- }
-
- override public function initialize() : void
- {
- super.initialize();
- }
-
- [Bindable(event="propertyChange")]
- public function set bundleName(param1:String) : void
- {
- var _loc2_:Object = this.bundleName;
- if(_loc2_ !== param1)
- {
- this._1377046061bundleName = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"bundleName",_loc2_,param1));
- }
- }
-
- [Bindable(event="propertyChange")]
- public function set useHTML(param1:Boolean) : void
- {
- var _loc2_:Object = this.useHTML;
- if(_loc2_ !== param1)
- {
- this._148395598useHTML = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"useHTML",_loc2_,param1));
- }
- }
-
- protected function ensureGlyphs(param1:String) : void
- {
- var _loc2_:String = null;
- var _loc3_:Font = null;
- if(!this.isFontRetrieved)
- {
- this.isFontRetrieved = true;
- _loc2_ = getStyle("fontFamily");
- if(_loc2_.match(/,/))
- {
- return;
- }
- for each(_loc3_ in fontArray)
- {
- if(_loc3_.fontName == _loc2_)
- {
- this.cachedEmbeddedFont = _loc3_;
- this.defaultAppFontFamily = StyleManager.getStyleDeclaration("Application").getStyle("fontFamily");
- }
- }
- }
- if(this.cachedEmbeddedFont)
- {
- if(!this.cachedEmbeddedFont.hasGlyphs(param1))
- {
- setStyle("fontFamily",this.defaultAppFontFamily);
- }
- else
- {
- setStyle("fontFamily",this.cachedEmbeddedFont.fontName);
- }
- }
- }
-
- [Bindable(event="propertyChange")]
- public function set resourceParams(param1:Array) : void
- {
- var _loc2_:Object = this.resourceParams;
- if(_loc2_ !== param1)
- {
- this._143661260resourceParams = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"resourceParams",_loc2_,param1));
- }
- }
-
- private function set _148395598useHTML(param1:Boolean) : void
- {
- this._useHTML = param1;
- invalidateProperties();
- }
-
- public function get useHTML() : Boolean
- {
- return this._useHTML;
- }
-
- public function get resourceParams() : Array
- {
- return this._resourceParams;
- }
-
- public function get resourceName() : String
- {
- return this._resourceName;
- }
-
- public function get bundleName() : String
- {
- return this._bundleName;
- }
- }
- }
-
-